Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REPL Autoload file #1009

Merged
merged 7 commits into from
Aug 14, 2014
Merged

REPL Autoload file #1009

merged 7 commits into from
Aug 14, 2014

Conversation

bholt
Copy link
Contributor

@bholt bholt commented Aug 11, 2014

This PR enables users to specify commands that will automatically be executed when the REPL loads (such as including time zone, sources, etc).

So far, I have the repl loading a single file in the user's home directory (~/.scalding_repl).

Is there any value in trying to make it search other places for files, such as walking up to the root from the current directory (as many other configs do). This doesn't seem particularly useful for the way most people run from the root of the project.

@johnynek
Copy link
Collaborator

I guess it does sound nice to have it walk up to at least the user home directory so that each project can have its own custom imports. :/

Any way to test this?

@bholt
Copy link
Contributor Author

bholt commented Aug 11, 2014

Other things that might go in this PR/config:

  • Customize prompt (mostly because it'd be awesome to have a colored prompt, but ):

    // In .scalding_repl:
    ScaldingShell.prompt = Console.BLUE + "\nscalding> " + Console.RESET
    
    // in ScaldingILoop:
    override def prompt: String = ScaldingShell.prompt()

@bholt
Copy link
Contributor Author

bholt commented Aug 11, 2014

Any way to test this?

I think I can add another repl test to the script we already have. I'll give it a try.

@bholt bholt self-assigned this Aug 13, 2014
@bholt
Copy link
Contributor Author

bholt commented Aug 14, 2014

Now the REPL will automatically load files named ".scalding_repl" in your path. The prompt can also now be customized (presumably from in a .scalding_repl file, but can be done manually as well).

Ready for anyone who's interested to review this.

* up to root.
*/
private def findAllUpPath(filename: String): List[File] =
Iterator.iterate(System.getProperty("user.dir"))(new File(_).getParent)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you say current directory here, but you are actually getting the user's home dir.

I like the idea of a current directory so I could put some .scalding_repl file in my science directory have that different from my home. Am I missing this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this property is named kind of confusingly named: "user.dir" is the current working directory (of the user, I guess...)

scala> System.getProperty("user.dir")
res0: java.lang.String = /Users/bholt/dev/hub/scalding

scala> System.getProperty("user.home")
res1: java.lang.String = /Users/bholt

@johnynek
Copy link
Collaborator

Thanks for clearing me up there! :)

johnynek added a commit that referenced this pull request Aug 14, 2014
@johnynek johnynek merged commit b90473b into develop Aug 14, 2014
@johnynek
Copy link
Collaborator

also, can you add a quick note in the REPL wiki page about how to use this feature?

@bholt
Copy link
Contributor Author

bholt commented Aug 14, 2014

Roger, Rodger.

@bholt bholt deleted the bholt/repl-autoload branch August 14, 2014 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants